package com.inray.nbs.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.inray.nbs.bean.Userinfo;
import com.inray.nbs.bean.Userlog;
import com.inray.nbs.dao.BaseDao;
import com.inray.nbs.service.UserSetService;
import com.inray.nbs.vo.Menu;


@Service
public class UserSetServiceImpl implements UserSetService{
	@Resource(name="baseDaoImpl")
	protected BaseDao baseDao;

	@Override
	public List<Userinfo> selectUserData(Map<String, Object> map) {
		return baseDao.selectListBySqlId("Userinfo.selectUserData", map);
	}
	@Override
	public List<Userlog> selectLoginLogData(Map<String,Object> map){
		return baseDao.selectListBySqlId("Userlog.selectLoginLogData", map);
	}
	
	@Override
	public List<Menu> selectMenuData(){
		return baseDao.selectListBySqlId("User_role.selectMenuData", null);
	}
	@Override
	public int EditPaswEmail(Userinfo user){
		return baseDao.updateBySqlId("Userinfo.EditPaswEmail", user);
	}
	@Override
	public List<Userinfo> CheackLoginname(Map<String,Object> map){
		return baseDao.selectListBySqlId("Userinfo.CheackLoginname", map);
	}
	@Override
	public int addUser(Userinfo m){
		return baseDao.insert(m);
	}
	@Override
	public int delUser(Userinfo m) {
		return baseDao.delete(Userinfo.class, m.getUserid());
	}
	@Override
	public int editUser(Userinfo m) {
		return baseDao.update(m);
	}
	@Override
	public int ForcedUser(Userinfo m) {
		return baseDao.updateBySqlId("Userinfo.ForcedUser", m);
	}
	@Override
	public int SaveCtrlVehicle(Userinfo m){
		return baseDao.updateBySqlId("Userinfo.SaveCtrlVehicle", m);
	}
	@Override
	public int SaveIpAddr(Userinfo user){
		int i=1;
		Userlog log = new Userlog();
		log.setUserid(user.getUserid());
		log.setLoginip(user.getIp());
		//baseDao.insert(log);
		return i;
	}
}
